package net.entelijan.cobean.tree;

import javax.swing.Icon;

import net.entelijan.cobean.util.CobeanUtil;

public class SimpleIconMapper<T> implements IIconMapper<T> {

	private String resourceName;

	private Icon icon;

	public SimpleIconMapper() {
		super();
	}

	public SimpleIconMapper(String resourceName) {
		super();
		this.resourceName = resourceName;
	}

	@Override
	public Icon getIcon(T model) {
		if (icon == null) {
			icon = CobeanUtil.loadIcon(resourceName);
		}
		return icon;
	}

	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}

	public String getResourceName() {
		return resourceName;
	}

}
